<html>
<head>
    <link rel="stylesheet" type="text/css" href="/static/easyui/themes/metro/easyui.css" id="_stylesheet_">
    <link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/static/css/admin.css?v=0.0.1">
    <link rel="stylesheet" href="/static/editor/themes/default/default.css"/>
    <style type="text/css">
        #id_controller, #id_form,#id_detail,#id_model {
            left: 0;
            right: 0;
            top: 0;
            bottom: 20px;
            padding: 10px;
            height: 100%;
            width: 100%;
            overflow: auto;
        }
    </style>
</head>
<body>

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north',title:'工具栏(手机版工具)'" style="height:80px;">
        <div style="padding-top:15px;padding-left:20px;vertical-align: middle">
            <form id="selections">
                <select id="id_table" name="name">
                    <option value="">请选择</option>
                    {volist name="tableList" id="vo"}
                    <option value="{$vo.name}=>{$vo.title}">{$vo.name}=>{$vo.title}</option>
                    {/volist}
                </select>
                <a href="javascript:void(0)" id="btnGo" class="easyui-linkbutton" style="margin-left:20px;">生成代码</a>
                <div style="display: inline-block;margin-left:50px;">
                    <input type="checkbox" name="form" value="1" checked="checked">
                    表单
                    <input type="checkbox" name="controller" value="1" checked="checked">
                    控制器
                    <input type="checkbox" name="model" value="1" checked="checked">
                    模型
                </div>
                <a href="javascript:void(0)" id="btnGoFile" class="easyui-linkbutton" style="margin-left:20px;">生成文件</a>
                <input id="result" type="text" readonly="readonly"/>
            </form>
        </div>
    </div>
    <div data-options="region:'center',fit:true,border:false">
        <div class="easyui-layout" data-options="fit:true">
            <div data-options="region:'west',border:false" style="width:50%;position: relative">
                <div class="easyui-layout" data-options="fit:true,border:false">
                    <div data-options="region:'north',border:false,title:'表单'" style="height:50%;position: relative">
                        <textarea id="id_form"></textarea>
                    </div>
                    <div data-options="region:'center',border:false,title:'详细'" style="position: relative">
                        <textarea id="id_detail"></textarea>
                    </div>
                </div>
            </div>
            <div data-options="region:'center',border:true">
                <div class="easyui-layout" data-options="fit:true,border:false">
                    <div data-options="region:'north',border:false,title:'控制器'" style="height:50%;position: relative">
                        <textarea id="id_controller"></textarea>
                    </div>
                    <div data-options="region:'center',border:false,title:'模型'" style="position: relative">
                        <textarea id="id_model"></textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script>

    $('#btnGo').click(function () {
        var table = $('#id_table').val();
        if (!table) {
            $.messager.alert({title:'提示',content:'前选择'});
            return;
        }
        $.messager.progress();
        $.get('{:U("getCodeForWeixin")}', {name: table}, function (data) {
            $.messager.progress('close');
            $('#id_form').val(data.form);
            $('#id_controller').val(data.controller);
            $('#id_model').val(data.modal);
            $('#id_detail').val(data.detail);
        }, 'json');
    });
    $('#btnGoFile').click(function () {
        var table = $('#id_table').val();
        if (!table) {
            Messager.alert('请选择');
            return;
        }
        $.messager.progress();
        var data = $('#selections').serialize();
        $.get('{:U("createFileForWeixin")}', data, function (data) {
            $.messager.progress('close');
            $.messager.show({title:'提示',content:'操作成功'});
            $('#result').val(data);
        }, 'json');
    });
</script>
</body>
</html>
